import { FormInstance } from "element-plus";
import { SFGridSchema, SFSchema, SFUISchemaItem } from "./interface";
import { SFItemService } from "./sf-item/sf-item.service";
import { SFService } from "./sf.service";

export type SFDLSSize = "large" | "default" | "small";
export type SFSchemaType = "number" | "string" | "boolean" | "object" | "array";
export type SFBuiltInWidgets =
  | "text"
  | "string"
  | "inputNumber"
  | "colorPicker"
  | "integer"
  | "date"
  | "time"
  | "radio"
  | "checkbox"
  | "boolean"
  | "textarea"
  | "select"
  | "tree-select"
  | "tag"
  | "upload"
  | "transfer"
  | "slider"
  | "rate"
  | "autocomplete"
  | "cascader"
  | "mention"
  | "custom"
  | "array"
  | "object";

export type TChange<T = NzSafeAny> = (val: T) => void;
export type TValidated = (
  value: NzSafeAny,
  rule?: {
    field?: string;
    fullField?: string;
    fullFields?: string[];
  },
  callback?: (error?: string | Error) => void
) => boolean | Error | Error[];
export type NzSafeAny = any;
export type SFOption = {
  schema: SFSchema<SFUISchemaItem>;
  ui?: SFGridSchema;
  layout?: "inline-flex" | "block";
};

export type TFormOption = {
  moda: "search" | "edit";
  labelPosition?: "left" | "right" | "top";
  labelWidth?: number;
  labelSuffix?: string;
  requirePosition?: "left" | "right";
  disabled?: boolean;
  data?: Record<string, NzSafeAny>;
  schema?: SFSchema<SFUISchemaItem>;
  ui?: SFGridSchema;
  keyPath?: string;
  searchSpan?: number;
};

export type TItemOption<T = SFUISchemaItem> = {
  field: string;
  keyPath: string;
  service: SFItemService<T>;
};

export type SFInstance = {
  service: SFService;
  reset: () => void;
  vaild: boolean;
  form: FormInstance;
};
